package com.zoer.hibdao;

// default package

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;

import com.zoer.domain.ChildrenForbid;

/**
 * A data access object (DAO) providing persistence and search support for
 * ChildrenForbid entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see .ChildrenForbid
 * @author MyEclipse Persistence Tools
 */

public class ChildrenForbidDAO extends BaseHibernateDAO {
	private static final Log log = LogFactory.getLog(ChildrenForbidDAO.class);

	// property constants

	public void save(ChildrenForbid transientInstance) {
		log.debug("saving ChildrenForbid instance");
		try {
			Session s = getSession();
			s.beginTransaction();
			s.save(transientInstance);
			s.getTransaction().commit();
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(ChildrenForbid persistentInstance) {
		log.debug("deleting ChildrenForbid instance");
		try {
			Session s = getSession();
			s.beginTransaction();
			s.delete(persistentInstance);
			s.getTransaction().commit();
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public ChildrenForbid findById(java.lang.String id) {
		log.debug("getting ChildrenForbid instance with id: " + id);
		try {
			ChildrenForbid instance = (ChildrenForbid) getSession().get(
					"com.zoer.domain.ChildrenForbid", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding ChildrenForbid instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from ChildrenForbid as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findAll() {
		log.debug("finding all ChildrenForbid instances");
		try {
			String queryString = "from ChildrenForbid";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
}